package assignment.quocthai;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class MyDatabaseHelper extends SQLiteOpenHelper {

	static final String DATABASE_NAME = "my_account_db.db";
	static final int DATABASE_VERSION = 1;
	static final String DATABASE_CREATE = "create table account (id integer primary key autoincrement, server_name String, username String, password String);";
	
	public MyDatabaseHelper(Context context){
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}
	
	public MyDatabaseHelper(Context context, String name,
			CursorFactory factory, int version) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public void onCreate(SQLiteDatabase arg0) {
		// TODO Auto-generated method stub
		arg0.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub
		Log.w(MyDatabaseHelper.class.getName(), "Upgrading database from version " + arg1 + " to " + arg2 + ", which will destroy all old data");
		arg0.execSQL("drop table if exists account");
//		onCreate(arg0);
	}

}
